package tech.soulcoder.core.audit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author yunfeng.lu
 * @date 2018/9/24
 */
public interface IAuditService {
    void audit(int operatorId, String operator, String action, Object[] params, String mainType,
               String subType);

    /**
     * 审计服务--日志实现  默认审计实现只打日志不提供持久化操作
     */
    class LogAuditImpl implements IAuditService {
        private static final Logger logger = LoggerFactory.getLogger(LogAuditImpl.class);

        @Override
        public void audit(int operatorId, String operator, String action, Object[] params, String mainType,
                          String subType) {
            logger.info("[{}][{}] operator:{}({}) do {} with params:{}", mainType, subType, operator, operatorId,
                    action, params);
        }
    }
}